package com.tech.zhidengxian.util;

import com.alibaba.fastjson.JSON;
import com.tech.zhidengxian.model.constant.GoodsState;
import com.tech.zhidengxian.model.dto.GoodsDTO;
import com.tech.zhidengxian.model.dto.SchoolDTO;
import com.tech.zhidengxian.model.dto.UserDTO;

import java.util.Date;
import java.util.Random;
import java.util.UUID;

public class MockUtil {
    private static Random random = new Random();
    public static String randomUUID(){
        return UUID.randomUUID().toString().substring(8) + new Date().getTime();
    }
    public static UserDTO mockUserDTO(){
        UserDTO userDTO = new UserDTO();
        userDTO.setId(random.nextLong());
        userDTO.setUsername("susu");
        userDTO.setEmail("8219310@163.com");
        userDTO.setImageUrl("/img/user/"+randomUUID());
        userDTO.setPhone("13823948817");
        userDTO.setSchoolInfo(JSON.parseObject("{\"id\": 1766, \"city\": \"长沙市\", \"name\": \"中南大学\", \"province\": \"湖南省\"}",SchoolDTO.class));
        userDTO.setUpdateTime(new Date());
        userDTO.setRegisterTime(new Date());
        return userDTO;
    }
    public static GoodsDTO mockGoodsDTO(){
        UserDTO userDTO = mockUserDTO();
        GoodsDTO goodsDTO = new GoodsDTO();
        goodsDTO.setGoodsState(GoodsState.selling);
        goodsDTO.setSchool("中南大学");
        goodsDTO.setCollectCount(0l);
        goodsDTO.setCommentCount(0l);
        goodsDTO.setBrowseCount(0l);
        goodsDTO.setDetail("毕业离校了着急出一批教材，看上的私聊白菜价,大甩卖大甩卖大甩卖大甩卖大甩卖");
        goodsDTO.setPublisherInfo(userDTO);
        goodsDTO.setPrice(199.0);
        goodsDTO.setUid(userDTO.getId());
//        goodsDTO.setImageUrl("/img/goods/"+randomUUID()+".png");
        return goodsDTO;
    }
}
